using System;
using System.Collections.Generic;
using System.Linq;
using GalaSoft.MvvmLight;

namespace Locator.Silverlight.Client.Models.ViewModels.Elements
{
    public class UserStoreViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the UserStoreViewModel class.
        /// </summary>
        public UserStoreViewModel(StoreViewModel store)
        {
            this.Store = store;
        }

        /// <summary>
        /// The <see cref="UsedByUser" /> property's name.
        /// </summary>
        public const string UsedByUserPropertyName = "UsedByUser";

        private bool usedByUser;

        /// <summary>
        /// Gets the UsedByUser property.
        /// TODO Update documentation:
        /// Changes to that property's value raise the PropertyChanged event. 
        /// This property's value is broadcasted by the Messenger's default instance when it changes.
        /// </summary>
        public bool UsedByUser
        {
            get { return usedByUser; }

            set
            {
                if (usedByUser == value)
                {
                    return;
                }

                usedByUser = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(UsedByUserPropertyName);
            }
        }

        public StoreViewModel Store { get; set; }

        public int Index { get; set; }
    }
}
